# -*- coding:utf-8 -*-
"""
Django settings for health_spa project.
"""

import os
import sys


# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/
sys.path.insert(0, os.path.join(BASE_DIR, 'apps'))
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'fek9x^pj%i7be_#uyv&uvhslvm@f6p8(m!la8^6#d_$vq4d&@*'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = []


# Application definition

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'apps.Account',
    'apps.app_setting',
    "apps.customers",
    "apps.main",
]
# 'debug_toolbar',
MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware'

]
# 'debug_toolbar.middleware.DebugToolbarMiddleware'
ROOT_URLCONF = 'health_spa.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR, 'templates')],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

WSGI_APPLICATION = 'health_spa.wsgi.application'

# debug 工具栏定义jquery路径
# DEBUG_TOOLBAR_CONFIG = {
#     'JQUERY_URL': r"http://code.jquery.com/jquery-2.1.1.min.js"
#     }
# Database
# https://docs.djangoproject.com/en/1.11/ref/settings/#databases
"""
mysql数据库配置文件在项目根路径下的mysql.cnf，
使用时将mysql.sample.cnf按自己的配置填入并改名为mysql.cnf

"""
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'OPTIONS': {
            'read_default_file': os.path.join(BASE_DIR, 'mysql.cnf'),
            'init_command': "SET storage_engine=INNODB; SET sql_mode='STRICT_TRANS_TABLES';"
        }
    }
    # 'default': {
    #     'ENGINE': 'django.db.backends.sqlite3',
    #     'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    # }
}


# Password validation
# https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
    {
        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
    },
]


# Internationalization
# https://docs.djangoproject.com/en/1.11/topics/i18n/

LANGUAGE_CODE = 'zh-hans'

TIME_ZONE = "Asia/Shanghai"

USE_I18N = True

USE_L10N = True

USE_TZ = True

DATE_FORMATS = 'Y-m-d'

INTERNAL_IPS = ('127.0.0.1',)


APPEND_SLASH = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.11/howto/static-files/

STATIC_URL = '/static/'
STATICFILES_DIRS = (
    os.path.join(BASE_DIR, "static"),
    # '/path/to/others/static/',
)

LOGIN_URL = '/auth/login/'
